home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doPlayblastArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  10.4 KB  |  386 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Nov. 24/97
  22. //  Author:         ajp
  23. //
  24. //  Description:
  25. //        doPlayblast is the actual proc that is executed from the
  26. //    Windows->Playblast option box or menu
  27. //
  28. //  Input Arguments:
  29. //
  30. //  Return Value:
  31. //        none
  32. //
  33.  
  34. // This proc will generate a confirmation box.  It is used when
  35. // a playblast file is about to be overwritten.
  36. //
  37. proc string confirmPlayblastOverwrite( string $type, string $filename )
  38. {
  39.     string $message;
  40.     string $showFilename;
  41.  
  42.     if (`exists Win32Init`)
  43.     {
  44.         $showFilename = unconvert($filename);
  45.     }
  46.     else
  47.     {
  48.         $showFilename = ($filename);
  49.     }
  50.  
  51.     switch ($type) {
  52.         case "sgi":
  53.             $message = ("File \"" + $showFilename + "\" exists.  Overwrite?");
  54.             break;
  55.         case "iff":
  56.             $message = ("fcheck files exist with the prefix \""
  57.                         + $showFilename
  58.                         + "\" which may be overwritten.  Continue?");
  59.             break;
  60.         case "qt":
  61.             $message = ("File \"" + $showFilename + "\" exists.  Overwrite?");
  62.             break;
  63.             
  64.         default:
  65.             $message = ("File \"" + $showFilename + "\" exists.  Overwrite?");
  66.             break;
  67.     }
  68.  
  69.     string $result = `confirmDialog
  70.         -t "Playblast Error: File Exists"
  71.         -m $message
  72.         -ma center
  73.         -b "Ok"
  74.         -b "Cancel"
  75.         -db "Cancel"
  76.         -cb "Cancel"
  77.         -ds "Cancel"`;
  78.     return $result;
  79. }
  80.  
  81.  
  82. //  Creation Date:  11 Nov 98
  83. //  Author:         mw
  84. //
  85. //  Description:
  86. //    doPlayblastArgList allows for a variable number
  87. //    or arguments to be passed in through a string array.
  88. //    This is not possible through the fixed-arg proc doPlayblast
  89. //
  90. //  Input Arguments:
  91. //    $version: The version of this option box.  Used to know how to 
  92. //    interpret the $args array.
  93. //        "1" : $whichRange, $timeRange, $option, $hierarchy,
  94. //                $doControlPoints, $doShapes, $useChannelBox,
  95. //                $selectionConnection
  96. //        "2" : $options
  97. //
  98. //    $args
  99. //    Version 1
  100. //    [0]        $saveIt                0/1 
  101. //    [1]        $movie                name of movie if $saveIt is 1
  102. //    [2]        $isViewer            0/1
  103. //    [3]        $format                sgi/iff
  104. //    [4]        $showOrnaments        0/1
  105. //    [5]        $scale                scale source images by this amount    
  106. //    [6]        $compression        0/1
  107. //    [7]        $displaySource        what do we use to determine movie width/height
  108. //                                1 : Use current view
  109. //                                2 : Use Render Globals
  110. //                                3 : Use values specified from option box
  111. //    [8]        $displayWidth        requested width of movie
  112. //    [9]        $displayHeight        requested height of movie
  113. //
  114. //    Version 2
  115. //    [10]    $useStartEnd        0 : Use playback range (or highlighted range)
  116. //                                1 : Use user-specified start/end
  117. //  [11]    $startTime          time to start playblast                      
  118. //  [12]    $endTime            time to end playblast   
  119. //
  120. //    Version 3            
  121. //    [13]    $clearCache            0 : Leave previous temporary files
  122. //                                1 : Delete temporary files from all previous
  123. //                                    playblasts
  124. //                                  
  125. //  Return Value:
  126. //      The number of curves from which keys were cut.
  127. //
  128. global proc doPlayblastArgList( string $versionStr, string $args[] )
  129. {
  130.     int $version = $versionStr;
  131.  
  132.     string $saveIt = $args[0];
  133.     string $movie = $args[1];
  134.     int $isViewer = $args[2];
  135.     string $format = $args[3];
  136.     int $showOrnaments = $args[4];
  137.     float $scale = $args[5];
  138.     string $compression = $args[6];
  139.     int $displaySource = $args[7];
  140.     int $displayWidth = $args[8];
  141.     int $displayHeight = $args[9];
  142.  
  143.     int $useStartEnd = ($version >= 2 ? $args[10] : 0);
  144.     float $startTime = ($version >= 2 ? $args[11] : 1.0);
  145.     float $endTime = ($version >= 2 ? $args[12] : 10.0);
  146.  
  147.     int $clearCache = ($version >= 3 ? $args[13] : 1);
  148.  
  149.     global string $gPlayBackSlider;
  150.  
  151.     string $cmd = "playblast ";
  152.  
  153.     // Use given start/end times
  154.     //
  155.     if( $useStartEnd ) {
  156.         $cmd = ( $cmd+"-startTime "+$startTime+" -endTime "+$endTime + " " );
  157.     }
  158.     // Time range of the blast comes from Highlight, or playback
  159.     // range if no highlight.
  160.     //
  161.     else {
  162.         if( `timeControl -q -rangeVisible $gPlayBackSlider` ) {
  163.             float $range[] = `timeControl -q -rangeArray $gPlayBackSlider`;
  164.             // The range query returns the max value as the right edge
  165.             // of the range.  This is really one frame higher than we want 
  166.             // to playblast.
  167.             //
  168.             $cmd = ( $cmd + "-startTime " + $range[0] + 
  169.                      " -endTime " + ($range[1] - 1.0) + " " );
  170.         }
  171.     } 
  172.  
  173.     // if the "Save to File" flag is on and the
  174.     // file already exists, we need to confirm if the
  175.     // user wants to overwrite it
  176.     //
  177.     string $forceOverwriteFlag = "";
  178.     if ( $saveIt ) {
  179.  
  180.         // the $movie string can be relative or absolute;
  181.         // need to resolve it here
  182.         //
  183.         string $path = "";    // just the directory path
  184.         string $filename = ""; // just the filename
  185.  
  186.         if ( substring($movie,1,1) != "/" && substring($movie,1,1) != "$" 
  187.             && (size($movie)>1 && substring($movie,2,2) != ":")) {
  188.  
  189.             // relative path, get the project's image directory
  190.             //
  191.             string $fileRules[] = `workspace -q -rt`;
  192.             int $i;
  193.             string $imageDir = ""; // default
  194.             for ( $i = 0; $i < size($fileRules); $i += 2 ) {
  195.                 if ( $fileRules[$i] == "images" ) {
  196.                     $imageDir = $fileRules[$i+1];
  197.                     break;
  198.                 }
  199.             }
  200.             $path = (`workspace -q -fn` + "/" + $imageDir + "/");
  201.             $filename = $movie;
  202.  
  203.         } else {
  204.  
  205.             // absolute path
  206.             //
  207.             int $index = 0;
  208.             for( $index = size($movie); $index > 0; $index-- ) {
  209.                 if ( substring($movie,$index,$index) == "/"
  210.                     || substring($movie,$index,$index) == "$" ) {
  211.                     break;
  212.                 }
  213.             }
  214.  
  215.             $path = substring($movie,1,$index);
  216.             $filename = substring($movie,$index+1,size($movie));
  217.         }
  218.  
  219.         if ( $format == "sgi" || $format == "qt" ) {
  220.  
  221.             // need to check for the ".mv" extension which
  222.             // is added in the playblast code if it doesn't
  223.             // already exist
  224.             //
  225.             string $tokens[];
  226.             tokenize($filename,".",$tokens);
  227.             if (`exists Win32Init`)
  228.             {
  229.                 if ( $tokens[size($tokens)-1] != "avi" ) {
  230.                     $filename += ".avi";
  231.                 }
  232.             }
  233.             else if(`about -mac`)
  234.             {
  235.                 if ( $tokens[size($tokens)-1] != "qt" ) {
  236.                     $filename += ".qt";
  237.                 }
  238.             }
  239.             else
  240.             {
  241.                 if ( $tokens[size($tokens)-1] != "mv" ) {
  242.                     $filename += ".mv";
  243.                 }
  244.             }
  245.             // bring up a confirm dialog if the file already exists
  246.             //
  247.             if ( `file -q -exists ($path+$filename)` ) {
  248.                 string $result = `confirmPlayblastOverwrite sgi $movie`;
  249.                 if ( $result == "Ok" ) {
  250.                     $forceOverwriteFlag = " -forceOverwrite ";
  251.                 } else {
  252.                     return;
  253.                 }
  254.             }
  255.  
  256.         } else {
  257.  
  258.             // need to check for files with this $movie as the
  259.             // prefix and ending in ".iff"
  260.             //
  261.             int $i;
  262.             string $regExp = ($filename+"\.*\.iff");
  263.             string $dirListing[] = `workspace -l $path`;
  264.             for ( $i = 0; $i < size($dirListing); $i++ ) {
  265.                 if ( match($regExp,$dirListing[$i]) != "" ) {
  266.                     // fcheck files exists with this prefix
  267.                     //
  268.                     string $result = `confirmPlayblastOverwrite iff $movie`;
  269.                     if ( $result == "Ok" ) {
  270.                         $forceOverwriteFlag = " -forceOverwrite ";
  271.                         break;
  272.                     } else {
  273.                         return;
  274.                     }
  275.                 }
  276.             }
  277.         }
  278.     }
  279.  
  280.     // See if there's sound in the time slider
  281.     //
  282.     int    $isSound  = `timeControl -q -ds $gPlayBackSlider`;
  283.     string $sound     = `timeControl -q -s $gPlayBackSlider`;
  284.  
  285.     // convert old format flags to the new ones
  286.     //
  287.     if ($format == "sgi" || $format == "qt") $format = "movie";
  288.     else $format = "image";
  289.  
  290.     // Output format
  291.     //
  292.     $cmd = ( $cmd + " -format " + $format );
  293.     
  294.     // If the time slider is displaying sound, use it.
  295.     // Otherwise, don't.
  296.     //
  297.     // Fix for bug #141346
  298.     // Was not playing sound with movies. It only playing sound if
  299.     // $format=="sgi", but note that 11 lines up, if $format=="sgi"
  300.     // we set $format to "movie".
  301.     //
  302.     if(( $format == "movie" )
  303.     && ( $isSound )
  304.     && ( size( $sound ) > 0 ) )
  305.     {
  306.         $cmd = ( $cmd + " -sound \"" + $sound + "\"" );
  307.     }
  308.  
  309.     if( $saveIt ) {
  310.         if( size( $movie ) > 0 ) {
  311.             $cmd = ( $cmd + " -filename \"" + $movie + "\"" + $forceOverwriteFlag );
  312.         } else {
  313.             // We have to catch this error; otherwise it throws
  314.             // up the call stack window.
  315.             //
  316.             if( catch( `error( "\"Save to file\" requires filename" )` ) ) {
  317.                 return;
  318.             }
  319.         }    
  320.     }
  321.     
  322.     // Clear cache
  323.     //
  324.     $cmd = ($cmd + " -clearCache " + $clearCache);
  325.  
  326.     // Add the viewer flag
  327.     //
  328.     $cmd = ( $cmd + " -viewer " + $isViewer );
  329.  
  330.     // Show ornaments
  331.     //
  332.     $cmd = ($cmd + " -showOrnaments " + $showOrnaments);
  333.  
  334.     // Add the percentage from our scale value
  335.     //
  336.     $cmd = ( $cmd + " -percent " + 
  337.              string( int( $scale * 100 ) ) );
  338.     
  339.     // Add the compression
  340.     //
  341.     if( $format == "movie" ) {
  342.         $cmd = ( $cmd + " -compression " + $compression );
  343.     }
  344.  
  345.     // Display size
  346.     //
  347.     switch ($displaySource) {
  348.       case 1:
  349.         break;
  350.       case 3:
  351.         $cmd = ($cmd + " -widthHeight " + $displayWidth + " " + $displayHeight);
  352.         break;
  353.       default:
  354.         // Find the render globals
  355.         //
  356.         string $renderGlobals[] = `ls -type renderGlobals`;
  357.         if (size ($renderGlobals) == 0) {
  358.             warning ("Unable to find render globals");
  359.             return;
  360.         }
  361.         string $connections[] = `listConnections $renderGlobals[0]`;
  362.         if (size ($connections) == 0) {
  363.             warning ("No resolution specified");
  364.             return;
  365.         }
  366.         // Find the default resolution node
  367.         //
  368.         string $resolutionNode = "";
  369.         for ($i = 0; $i < size ($connections); $i++) {
  370.             if (`nodeType $connections[$i]` == "resolution") {
  371.                 $resolutionNode = $connections[$i];
  372.             }
  373.         }
  374.         if (size ($resolutionNode) == 0) {
  375.             warning ("No resolution specified");
  376.             return;
  377.         }
  378.         int $resDisplayWidth = `getAttr ($resolutionNode + ".width")`;
  379.         int $resDisplayHeight = `getAttr ($resolutionNode + ".height")`;
  380.         $cmd = ($cmd+" -widthHeight "+$resDisplayWidth+" "+$resDisplayHeight);
  381.         break;
  382.     }
  383.  
  384.     evalEcho( $cmd );
  385. }
  386.